package com.shujunjun.project.strategy.more;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author wsh
 * @since 2024/3/17 11:20
 */
@Component
public class MoreStrategy {

    private final Map<String, More> map = new ConcurrentHashMap<>();

    /**
     * 注册bean
     *
     * @param name key
     * @param more value
     */
    public void register(String name, More more) {
        if (StringUtils.isEmpty(name) || null == more) {
            return;
        }
        map.put(name, more);
    }

    /**
     * 获取注册对象
     *
     * @param name key
     * @return value
     */
    public More getMoreInstance(String name) {
        return map.get(name);
    }
}
